import requests, random, time


def add_bottle(name, uid, state, type, bro_date, loc, size):
    data = {
        'name': name,
        'uid': uid,
        'state': state,
        'type': type,
        'bro_date': bro_date,
        'loc': loc,
        'size': size,
        }
    res = requests.post('http://127.0.0.1:8000/airhub/addbottle/', data)
    print(res.text)

def chang_bottle(id, state, loc, person):
    data = {
        'bottle_id': id,
        'state': state,
        'loc': loc,
        'person': person,
    }
    res = requests.post('http://127.0.0.1:8000/airhub/changebottle/', data)
    print(res.text)


# i=50
# while i < 100:
#     name = '气瓶' + str(i)
#     uid = str(i)
#     state = random.randint(1, 3)
#     type = random.randint(1, 3)
#     bro_date = '2022-' + str(random.randint(1, 12)) + '-' + str(random.randint(1, 27))
#     loc = random.randint(1, 5)
#     size = random.randint(1, 2)
#     add_bottle(name, uid, state, type, bro_date, loc, size)
#     i = i + 1

i = 1

bottle_id = random.randint(1, 99)
state = random.randint(1, 3)
loc = random.randint(1, 5)
person = random.randint(1, 5)
while i < 200:
    bottle_id = random.randint(1, 99)
    state = random.randint(1, 3)
    loc = random.randint(1, 5)
    person = random.randint(1, 5)
    chang_bottle(bottle_id, state, loc, person)
    i = i + 1

